/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mx.its.dswII.biblioteca.dao;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import mx.its.dswII.biblioteca.modelo.Autor;

/**
 *
 * @author Lenovo-user
 */
@Stateless
public class AutorDao extends AbstractDao<Autor> implements AutorDaoLocal {
    @PersistenceContext(unitName = "Biblioteca8E-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public AutorDao() {
        super(Autor.class);
    }
    public Boolean findDuplicity(Autor author){
    Query q= em.createNamedQuery("Autor.findDuplicity");
    q.setParameter("nombre", author.getNombre());
    q.setParameter("apellidoPaterno", author.getApellidoPaterno());
    q.setParameter("apellidoMaterno", author.getApellidoMaterno());
    return !q.getResultList().isEmpty();
    
    }
}
